﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Security.Cryptography;

/// <summary>
/// Summary description for ReturncountForRecipt
/// </summary>
/// 
namespace Bestlife.ERP.DataAccess
{
    public class ReturncountForRecipt:System.Web.UI.Page
    {
         SqlDataReader rdRStatus;
         Boolean bs = false;
         int p_chesid = 0;
        public ReturncountForRecipt()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        public int ReturnReciptID()
        {
            String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
            Bestlife.ERP.DataAccess.clsCon.connect(connStr);


            String sqlstatus = "SELECT COUNT(Pur_ID) as countids from Tbl_userPurchase";

            rdRStatus = clsCon.ReadTable(sqlstatus);


            if (rdRStatus.Read())
            {
                p_chesid = int.Parse(rdRStatus["countids"].ToString());
            }

            clsCon.conn_new.Close();
            rdRStatus.Close();

            p_chesid += 1;
            return p_chesid;
        }


        public string EncryptMd5(string url) 
        {
            MD5 md5 = MD5.Create();
            byte[] inputbytes = System.Text.Encoding.ASCII.GetBytes(url);
            byte[] hash = md5.ComputeHash(inputbytes);
            url = BitConverter.ToString(hash).Replace("-", "");
            string rtn = url.ToString();

            return rtn;
        }


        public Boolean launchurl(string urls) 
        {
            bs = true;
            //Response.Redirect(urls);
            HttpContext.Current.Response.Redirect(urls);
            return bs;
        }
    }
}